<?php 
header("content-type:text/html;charset=utf8");
$names = $_POST['names'];
$pwd = $_POST['pwd'];
$tel = $_POST['tel'];
$code = $_POST['code'];
$redis = new redis();
$redis->connect('127.0.0.1','6379');
$rediscode = $redis->get("code".$tel);
$pdo = new PDO("mysql:host=127.0.0.1;dbname=07c","root","root");
if($rediscode)
{
	if($rediscode == $code)
	{
		$sql = "insert into users values('','$names','$pwd','$tel','$code')";
		// print_r($sql);die;
		$res = $pdo->exec($sql);
		if($res)
		{
			$data = array("code"=>0,"msg"=>"注册成功");
		}
		else
		{
			$data = array("code"=>1,"msg"=>"注册失败");
		}
	}
	else
	{
		$data = array("code"=>2,"msg"=>"验证码错误");
	}
}else
{
	$data = array("code"=>3,"msg"=>"验证码失效");
}
echo json_encode($data);


 ?>